home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / graph_layout / fileio.hxx < prev    next >
Encoding:
Text File  |  1995-02-06  |  1.5 KB  |  45 lines

  1. /***************************************************************************
  2. **    TEST FILE FOR graph (Dynamic Layout Alg)
  3. **
  4. **    HEADER   - BUFFERED FILE INPUT WITH SYNTAX CHECK
  5. **        AND NOT BUFFERED FILE OUTPUT
  6. **
  7. ** Author: dr. Szirmay-Kalos Laszlo (szirmay@fsz.bme.hu)
  8. **       Technical University of Budapest, Hungary
  9. *****************************************************************************/
  10.  
  11. #ifdef MSWINDOWS
  12. #include "graph.hxx"
  13. #else
  14. #include "graph.hxx"
  15. #endif
  16.  
  17. #define BUFFERSIZE    2048
  18. #define MAXLINE        80
  19.  
  20.  
  21. class FileIO {
  22.     FILE *    file;            // file descriptor
  23.     char    operation[4];        // operation for open
  24.     int    line_count;        // number of inputed lines
  25.     int    error;            // error code
  26.     char    s[MAXLINE + 1];        // last string
  27.     int    buffpt;            // buffer indes
  28.     int    nbytes;            // number of valid bytes in buffer
  29.     char    buffer[BUFFERSIZE];    // io buffer
  30. protected:
  31.     BOOL    Get( pchar );            // get char and advance
  32.     void    UnGet( void ) { buffpt--; } // unget last char
  33. public:
  34.         FileIO( char * op ) { strcpy( operation, op ); }
  35.     BOOL    OpenFile ( pchar );        // open file having that name
  36.     BOOL    GetString ( pchar, int );   // get a string from the file
  37.     BOOL    GetKeyWord ( pchar );        // get a string and compare to a key
  38.     BOOL    GetKeyAgain ( pchar );        // get last string again and compare
  39.     BOOL    GetVariable ( double *, double, double );    // get a double variable
  40.     BOOL    GetOperator ( char );        // get a char and compare to the given char
  41.     int    GetLineNum ( void ) { return line_count;    }
  42.     BOOL    PutString ( pchar );        // write string to the file
  43.     void    CloseFile ( void );        // close file
  44. };
  45.